package il.ac.technion.wiki.api.wikidocument;

import il.ac.technion.wiki.api.wikidocument.content.ContentImporter;

import java.io.InvalidObjectException;
import java.util.Map;

/**
 *	Represents a document in the Wikipedia system.
 *	Each document contains its own title, content, current version, and may contain metadata.
 *	The version history is also kept so you can go back to a version if you like. 
 */
public interface IWikiDocument {
	void updateContent(String newContent);
	
	/**
	 * Update the content of the document (will cause to a change in the document's version)
	 * @param ci - ContentImporter that handles the specific content (e.g. HTML) 
	 */
	void updateContent(ContentImporter ci);

	/**
	 * Update the metadata of the document (will cause to a change in the document's version)
	 * @param metadata
	 */
	void updateMetadata(Map<String, String> metadata);
	
	String getTitle();
	
	/**
	 * @return the content of the current version
	 */
	String getContent();
	
	/**
	 * @return the metadata of the current version, may be null if the version doesn't contain metadata
	 */
	Map<String, String> getCurrentMetadata();
	
	Integer getCurrentVersion();
	
	/**
	 * @throws InvalidObjectException - if error version was given as an input
	 */
	void backToVersion(Integer version) throws InvalidObjectException;
	
	/**
	 * @return IWikiDocument that contain the same content and metadata as the version enquired. 
	 * @throws InvalidObjectException - if error version was given as an input
	 */
	IWikiDocument viewVersion(Integer version) throws InvalidObjectException;
}
